﻿using System;
using System.Data;
using System.Collections.Generic;
using System.Linq;
using System.Text;

using Com.Framework;

namespace Com.Library.SOAP.PointHistory
{
	public enum PointListType
	{
		None = 0,
		Add = 1,
		Used = 2
	}

	public class PointHistoryModel
	{
		public static List<PointHistoryEntity> GetList(DataSet ds, int PageNo, int PageSize, out int TotalRowCount)
		{
			List<PointHistoryEntity> list = new List<PointHistoryEntity>();
			TotalRowCount = 0;
			try
			{
				TotalRowCount = ds.Tables[0].Rows.Count;
			}
			catch { }

			int StartHistoryNo = ( PageNo -1) * PageSize;
			int EndHistoryNo = StartHistoryNo + PageSize;
			if (EndHistoryNo > TotalRowCount)
				EndHistoryNo = TotalRowCount;

			if (ds.Tables[0].Rows.Count > StartHistoryNo)
			{
				for (int i = StartHistoryNo; i < EndHistoryNo; i++)
				{
					try
					{
						DataRow row = ds.Tables[0].Rows[i];
						PointHistoryEntity info = new PointHistoryEntity();
						info.SetData("strCardNo", row["strCCardID"].Parse(string.Empty));
						info.SetData("strStoreName", row["strName"].Parse(string.Empty));
						info.SetData("n4AddPoint", row["lngAddPoint"].Parse(0));
						info.SetData("n4UsedPoint", row["lngUsedPoint"].Parse(0));
						info.SetData("dtCreateDate", row["dtmAddDate"].Parse(DateTime.MinValue));
						list.Add(info);
					}
					catch { }
				}
			}

			return list;
		}
	}
}
